package com.kmist.jianghu;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private static Context mContext;
    RadioGroup mr;
    static Player player;
    static MonsterLib monsterlib;

    public static void createNewPalyer(String name, String sex) {
        player.createPlayer(name, sex);
        Alarm("create Success");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.a_login_01);
        mContext = this;
        player = new Player(mContext);
        monsterlib = new MonsterLib();
        /*
        Button btn_newGame = findViewById(R.id.btn_newGame);
        btn_newGame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, JianHu.class);
                startActivity(intent);
            }
        });
        */

        Button btn_newGame = findViewById(R.id.login_btn01_newGame);
        Button btn_continue = findViewById(R.id.login_btn02_keepGame);
        btn_newGame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new CreatePlayerDialog(mContext);
            }
        });

        btn_continue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                player.loadPlayer();
                if(player.getmName().equals(""))
                {
                    Alarm("No Player!");
                }else{
                    player.loadPlayer();
                    Intent intent = new Intent(mContext, JianHu.class);
                    startActivity(intent);
                }
            }
        });
    }

    static void Alarm(String msg){
        Toast.makeText(mContext, msg, 0).show();
    }
}